<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>通过$slots来访问被slot分发的内容</title>
    <script src="../../js/vue.min.js"></script>
    <script src="../../js/iview.min.js"></script>
    <link rel="stylesheet" href="../../css/iview.css">
</head>
<body>
<div id="app">
    <child-component>
        <h2 slot="header">标题</h2>
        <p>正文内容</p>
        <p>更多正文内容</p>
        <div slot="footer">底部信息</div>
    </child-component>
</div>
<script>
    Vue.component('child-component', {
        template: "\
       <div class='container'>\
       <div class='header'><slot name='header'></slot></div>\
       <div class='main'><slot></slot></div>\
       <div class='footer'><slot name='footer'></slot></div>\
       </div>\
        ",
        mounted: function () {
            var header = this.$slots.header;
            var main = this.$slots.default;
            var footer = this.$slots.footer;
            console.log(footer);
            console.log(main);
            console.log(footer[0].elm.innerHTML);
        }
    });
    var app = new Vue({
        el: "#app"
    })
</script>
</body>
</html>